<%@page import="net.vinote.smart.platform.service.awe.layout.easyui.Datagrid"%>
<%@page import="net.vinote.smart.platform.service.dw.component.Component"%>
<%@page import="net.vinote.smart.platform.service.awe.layout.DataWindowList"%>
<%@page import="net.vinote.smart.platform.service.dw.html.ButtonTag"%>
<%@page import="net.vinote.smart.platform.service.awe.layout.ui.UILookAndFeel"%>
<%@page import="net.vinote.smart.platform.comm.StringFunction"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!-- 数据窗体选择器 -->
<%@include file="/comm/begin.jsp"%>
<%
	String doNo=request.getParameter("doNo");//显示模板名
	String params=request.getParameter("params");//查询参数,以逗号分隔
	String callback=request.getParameter("callback");//回调函数
	boolean isMulti="true".equals(request.getParameter("isMulti"));//是否多选
	String[] returnField=StringFunction.nullToBlank(request.getParameter("returnField")).split(",");
	UILookAndFeel uiAction=UILookAndFeel.getInstance();
	ButtonTag[] buttons=uiAction.getButtons(new String[][]{{"确定", "doSure()"},
			{"清空","clear()"}});
	DataWindowList list=new DataWindowList(request);
		list.addButtons(buttons,
				Component.NORTH);
	list.setShowCheckbox(isMulti);
	if(!isMulti){
		list.setEvent(Datagrid.EVENT_ON_DBL_CLICK_ROW, "doSure()");
	}
	
	if(params!=null&&params.length()>0){
		list.setParamVal(params.split(","));
	}
	list.setPageSize(20);
	list.setDoNo(doNo);
	out.print(list.getHtml());
%>
<script>
"use strict";
	function doSure(){
		var ids = [];
		var rows = $('#<%=doNo%>').datagrid('getSelections');
		for(var i=0;i<rows.length;i++){
			var returnObj={};
			<% 
			int length=returnField.length;
			for(int i=0;i<length;i++){
			%>
				returnObj['<%=returnField[i]%>']=rows[i].<%=returnField[i].toUpperCase()%>
			<%
			}
			if(isMulti){
			%>
			ids.push(returnObj);
			<%}else{
			%>
			ids=returnObj;
			<%}%>
		}
		<%
			if(callback!=null){
				%>
				parent.<%=callback%>(ids);
				<%
			}
		%>
	}
	
	function clear(){
		<%
		if(callback!=null){
			%>
			parent.<%=callback%>("_CLEAR_");
			<%
		}
	%>
	}
</script>
<%@include file="/comm/end.jsp"%>